<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NeuZephyr: nz::CudaException Class Reference</title>
<link rel="icon" href="NZ_logo2.png" type="image/x-icon" />
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="NZ_logo2.png"/></td>
  <td id="projectalign">
   <div id="projectname">NeuZephyr
   </div>
   <div id="projectbrief">Simple DL Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>nz</b></li><li class="navelem"><a class="el" href="classnz_1_1_cuda_exception.html">CudaException</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="classnz_1_1_cuda_exception-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">nz::CudaException Class Reference<span class="mlabels"><span class="mlabel">final</span></span></div></div>
</div><!--header-->
<div class="contents">

<p>A final class that represents CUDA exceptions, inheriting from std::runtime_error.  
 <a href="#details">More...</a></p>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>A final class that represents CUDA exceptions, inheriting from std::runtime_error. </p>
<p>This class is designed to handle and provide detailed information about CUDA-related errors. It captures the file, line number, CUDA error code, and the expression that caused the error. By overriding the <code>what()</code> method, it can return a formatted error message with all these details.</p>
<h3><a class="anchor" id="autotoc_md84"></a>
Type Definitions:</h3>
<ul>
<li>None</li>
</ul>
<h3><a class="anchor" id="autotoc_md85"></a>
Key Features:</h3>
<ul>
<li><b>Error Information Capture</b>: Records the file, line number, CUDA error code, and the expression where the error occurred.</li>
<li><b>Formatted Error Message</b>: Generates a detailed and human - readable error message that includes all the captured information.</li>
</ul>
<h3><a class="anchor" id="autotoc_md86"></a>
Usage Example:</h3>
<div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;cuda_runtime.h&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Assume DL_API is a valid macro for visibility</span></div>
<div class="line"><span class="keyword">class </span>DL_API <a class="code hl_class" href="classnz_1_1_cuda_exception.html">CudaException</a> final : <span class="keyword">public</span> std::runtime_error {</div>
<div class="line">    <span class="comment">// Class definition as provided</span></div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> someCudaFunction() {</div>
<div class="line">    cudaError_t err = cudaMalloc(<span class="keyword">nullptr</span>, 1024);</div>
<div class="line">    <span class="keywordflow">if</span> (err!= cudaSuccess) {</div>
<div class="line">        <span class="keywordflow">throw</span> <a class="code hl_class" href="classnz_1_1_cuda_exception.html">CudaException</a>(__FILE__, __LINE__, err, <span class="stringliteral">&quot;cudaMalloc(nullptr, 1024)&quot;</span>);</div>
<div class="line">    }</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    <span class="keywordflow">try</span> {</div>
<div class="line">        someCudaFunction();</div>
<div class="line">    } <span class="keywordflow">catch</span> (<span class="keyword">const</span> CudaException&amp; e) {</div>
<div class="line">        std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;</div>
<div class="line">    }</div>
<div class="line">    <span class="keywordflow">return</span> 0;</div>
<div class="line">}</div>
<div class="ttc" id="aclassnz_1_1_cuda_exception_html"><div class="ttname"><a href="classnz_1_1_cuda_exception.html">nz::CudaException</a></div><div class="ttdoc">A final class that represents CUDA exceptions, inheriting from std::runtime_error.</div><div class="ttdef"><b>Definition</b> <a href="_neu_zephyr_cuda_error_handling_8cuh_source.html#l00062">NeuZephyrCudaErrorHandling.cuh:62</a></div></div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the buffer size of 1024 characters is sufficient for the error message. If the message exceeds this size, it will be truncated.</li>
<li>The <code>format_message()</code> method should be called during object construction to ensure the error message is properly formatted.</li>
</ul>
</dd></dl>
<dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/24 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_neu_zephyr_cuda_error_handling_8cuh_source.html#l00062">62</a> of file <a class="el" href="_neu_zephyr_cuda_error_handling_8cuh_source.html">NeuZephyrCudaErrorHandling.cuh</a>.</p>
</div><hr/>The documentation for this class was generated from the following file:<ul>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/include/NeuZephyr/<a class="el" href="_neu_zephyr_cuda_error_handling_8cuh_source.html">NeuZephyrCudaErrorHandling.cuh</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
